package chapter9.作业.实践;

import java.util.Scanner;

public class homework {
    public static void main(String[] args) {
        String[] a =new String[11];

        int chongtu=0;
        Scanner scan  =new Scanner(System.in);
        int count=0;
        int number=0;
        System.out.println("请问要输入数字吗？请输入y/n");
        Scanner q = new Scanner(System.in);
        String w = q.nextLine();
        LinkedUnorderedList bite0=new LinkedUnorderedList();
        LinkedUnorderedList bite1=new LinkedUnorderedList();
        LinkedUnorderedList bite2=new LinkedUnorderedList();
        LinkedUnorderedList bite3=new LinkedUnorderedList();
        LinkedUnorderedList bite4=new LinkedUnorderedList();
        LinkedUnorderedList bite5=new LinkedUnorderedList();
        LinkedUnorderedList bite6=new LinkedUnorderedList();
        LinkedUnorderedList bite7=new LinkedUnorderedList();
        LinkedUnorderedList bite8=new LinkedUnorderedList();
        LinkedUnorderedList bite9=new LinkedUnorderedList();
        LinkedUnorderedList bite10=new LinkedUnorderedList();

        while (w.equalsIgnoreCase("y")){

            System.out.println("请输入添加进的元素:");
            int an=scan.nextInt();
            number++;
            int num=an%11;
            String re=String.valueOf(an);
            if (num==0) {

                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite0.addToRear(a[num]);
                    count++;
                } else {
                    bite0.addToRear(re);
                   chongtu++;
                    count+=bite0.size()+1;
                   // System.out.println("bite0"+count);
                }
            }
            if (num==1) {

                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite1.addToRear(a[num]);
                    count++;
                } else {
                    bite1.addToRear(re);
                    chongtu++;
                    count+=bite1.size()+1;
                }
            }
            if (num==2) {

                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite2.addToRear(a[num]);
                    count++;
                } else {
                    bite2.addToRear(re);
                    chongtu++;
                    count+=bite2.size()+1;
                }
            }
            if (num==3) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite3.addToRear(a[num]);
                    count++;
                } else {
                    bite3.addToRear(re);
                    chongtu++;
                    count+=bite3.size()+1;
                }
            }
            if (num==4) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite4.addToRear(a[num]);
                    count++;
                } else {
                    bite4.addToRear(re);
                    chongtu++;
                    count+=bite4.size()+1;
                }
            }
            if (num==5) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite5.addToRear(a[num]);
                    count++;
                } else {
                    bite5.addToRear(re);
                    chongtu++;
                    count+=bite5.size()+1;
                }
            }
            if (num==6) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite6.addToRear(a[num]);
                    count++;
                } else {
                    bite6.addToRear(re);
                    chongtu++;
                    count+=bite6.size()+1;
                }
                //System.out.println(bite6.toString());
            }
            if (num==7) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite7.addToRear(a[num]);
                    count++;
                } else {
                    bite7.addToRear(re);
                    chongtu++;
                    count+=bite7.size()+1;
                }
            }
            if (num==8) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite8.addToRear(a[num]);
                    count++;
                } else {
                    bite8.addToRear(re);
                    chongtu++;
                    count+=bite8.size()+1;
                }
            }
            if (num==9) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite9.addToRear(a[num]);
                    count++;
                } else {
                    bite9.addToRear(re);
                    chongtu++;
                    count+=bite9.size()+1;

                }
            }
            if (num==10) {
                if (a[num] == null) {
                    a[num] = String.valueOf(an);
                    bite10.addToRear(a[num]);
                    count++;
                } else {
                    bite10.addToRear(re);
                    chongtu++;
                    count+=bite10.size()+1;
                }
            }
            System.out.println("请问还需要输入元素吗(输入y/n)");
            w=q.nextLine();
        }
        System.out.println("冲突次数为:"+chongtu);
     //   System.out.println(bite.toString());
       // System.out.println(Arrays.toString(a));
        System.out.println(count);
        System.out.println(number);
        Double n1= (double) count;
        Double n2= (double) number;
        Double nu=n1/n2;
        System.out.println("ASL:"+nu);

    }
}
